<template>
	<view class="pages">		
		<view class="page-wrap">
		 	<view class="search-container">
		 		<view class="search-container-bar" style="padding-right: 20rpx;">
					 <button  type="primary" class="btn_search" @click="addClick()" size="mini">新增</button>
		 		</view>
		 	</view>
		</view>
		<scroll-list ref="list" @refresh="refresh">
			<uni-list class="uni-list" v-for="(item , index) in list" :key="index">
				<view >
					<uni-list-item :border="false" :title="'创建时间：'+item.gatherTime" class="diseaseList" :clickable="true" @click="listiemClick(item)">
            <view slot="footer">
              <text v-if="item.isAlarm == 1" style="color: rgba(255,40,40);">报警</text>
              <text v-if="item.isAlarm == 0" style="color: #808081;">不报警</text>
            </view>
          </uni-list-item>
					<uni-list-item class="diseaseList" :clickable="true" @click="listiemClick(item)">
						<text slot="header" class="diseaseList-header">点位：{{item.devname}}</text>
					</uni-list-item>
					<uni-list-item :border="false" class="diseaseList">
						<text slot="header">位置：{{item.locationDesc}}</text>
						<view slot="footer" style="display: flex;flex-direction:row;">
              <button v-if="item.isAlarm == 1" class="btn_ok" @click="handleClick(item)">处置</button>
						</view>
					</uni-list-item>
				</view>
			</uni-list>
		</scroll-list>
	</view>
</template>

<script>
	import { getList } from '../../../api/fishDegrade'
	export default {
		components: {},
		computed:{},
		data() {
			return {
				selectId:0,
				inputValue:'',
				list:[],
				searchForm:{}
			}
		},
		onShow() {
			this.list = []
			this.refresh({ page:1,size:10 })
		},
		methods: {
			getListData(paging){
				return new Promise((resolve, reject)=>{
				getList({ pageNum: paging.page,pageSize: paging.size }).then(res => {
						resolve(res)
					}, err => {
						reject(err)
					})
				})
			},
			//加载list
			load(paging) {
				this.getListData(paging).then(res =>{
					this.list = [...this.list, ...res.rows]
					this.$refs.list.loadSuccess({ list: this.list, total: res.total })
				}).catch(err =>{
					this.$refs.list.loadFail()
				})
			},
			//刷新list
			refresh(paging) {
				this.getListData(paging).then(res =>{
					this.list = res.rows
					this.$refs.list.refreshSuccess({ list: this.list, total: res.total })
				}).catch(err =>{
					this.$refs.list.refreshFail()
				})
			},
			search() {
				this.$refs.screeningDialog.close()
				this.$refs.list.refresh()
			},
			screeningClick(){
				this.$refs.screeningDialog.open()
			},
			addClick(){
				uni.navigateTo({ url: './edit', })
			},
			listiemClick(item){
        uni.setStorage({
          key:'detail',
          data:item,
          success:()=>{
            uni.navigateTo({ url: './edit?id='+item.id })
          }
        })
			},
			cancel(res) {
				this.searchForm.statusType = []
				this.searchForm.insertDateTime = ''
			},
			handleClick(item){
				uni.setStorage({
				  key:'detail',
				  data:item,
				  success:()=>{
				    uni.navigateTo({ url: './handle?id='+item.id })
				  }
				})
			},
			returnClick(id){
				this.selectId = id
				this.$refs.popupEdit.open()	
			},
			closeDialog() {
				this.$refs.popupEdit.close()
			}
		}
	}
</script>

<style lang="scss">
	@import '@/style/list.scss';
</style>
<style lang="scss">
	/* #ifndef APP-NVUE */
	view {
		display: flex;
		box-sizing: border-box;
		flex-direction: column;
	}
	/* #endif */
</style>